package com.huiyeji.hui.utils;

import com.huiyeji.hui.exception.ValidationException;

import java.util.regex.Pattern;

/**
 * @author zhaoduo
 */
public class PatternUtil{

    /**
     * 名称格式
     *  可匹配->群名称,用户昵称
     */
    public static final Pattern PATTERN_NAME = Pattern.compile("^.{1,12}$");

    /**
     * id 格式
     */
    public static final Pattern PATTERN_ID = Pattern.compile("^\\d{6}$");


    public static boolean test(Pattern pattern,String text){
        if (!pattern.matcher(text).matches()){
            throw new ValidationException();
        }
        return true;
    }
}
